package com.dragon.concurrent.demo.demo;

/**
 * @author dragon
 * @version V1.0.0-RELEASE
 * @date 2019/6/1 20:37
 */
public class AccountingSync extends Thread {

    static AccountingSync accountingSync = new AccountingSync();

    static int count = 0;

    @Override
    public void run() {

        int i = 0;
        for (; i < 10000000; i++) {
            count++;
//            synchronized (accountingSync) {
//
//            }
        }
        System.out.println(Thread.currentThread().getName() + ":结束" + i);
    }

    public static void main(String[] args) throws InterruptedException {
        AccountingSync t1 = new AccountingSync();
        AccountingSync t2 = new AccountingSync();
        t1.start();
        t2.start();
        t1.join(1);
        t2.join(1);
        System.out.println(count);
        for (int i = 0; i < 100; i++) {
            System.out.println("main" + i);
        }
        System.out.println(Thread.currentThread().getName() + ":结束");
    }
}
